package com.fer.tankr.controllers;

import org.andengine.engine.camera.Camera;
import org.andengine.entity.scene.menu.MenuScene;
import org.andengine.entity.scene.menu.MenuScene.IOnMenuItemClickListener;
import org.andengine.entity.scene.menu.item.IMenuItem;

import android.util.Log;

import com.fer.andenginemvc.api.Controller;
import com.fer.tankr.MainActivity;
import com.fer.tankr.scenes.HelpScene;
import com.fer.tankr.scenes.SceneManagerImpl;

public class HelpController extends Controller<MainActivity> implements IOnMenuItemClickListener{

	@Override
	public void onShow() {
		camera.setChaseEntity(scene);
		if (camera.getHUD()!=null)
		{
			camera.getHUD().detachSelf();
		}
	}
	
	public HelpController(MainActivity baseGame, Camera camera) {
		super(new HelpScene(camera,baseGame.getVertexBufferObjectManager(),baseGame.assetManager),baseGame, camera);
		getScene().setBackgroundEnabled(true);
		getScene().setOnMenuItemClickListener(this);
	}
	
	public HelpScene getScene()
	{
		return (HelpScene)scene;
	}

	@Override
	public boolean onMenuItemClicked(MenuScene pMenuScene, IMenuItem pMenuItem,
			float pMenuItemLocalX, float pMenuItemLocalY) {
		if (pMenuItem.getID() == HelpScene.IMG){
			Log.d("On Help Screen", "Back to main menu");
			baseGame.setScene(SceneManagerImpl.MENU);
		}
		else {
			baseGame.vibrate();
		}
		
		return true;
	}
}
